package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@SuppressWarnings("serial")
@Entity
@Table(name = "VENTAS")
public class Venta implements Serializable{
	private Integer id;
	private Cliente cliente;
	//private List<Cotizacion> cotizaciones;// para q esta?
	private List<ItemVenta> items = new ArrayList<ItemVenta>();
	
	public Venta() {
		super();
	}
	public Venta(Cliente cliente, List<Cotizacion> cotizaciones, Double descuento,
			List<ItemVenta> items) {
		super();
		this.cliente = cliente;
		//this.cotizaciones = cotizaciones;
		this.items = items;
	}
    @Id 
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id_venta")
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
    @ManyToOne
    @JoinColumn(name = "id_cliente")
	public Cliente getCliente() {
		return cliente;
	}
	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}

	@OneToMany(mappedBy = "venta", cascade = CascadeType.ALL)
	public List<ItemVenta> getItems() {
		return items;
	}
	public void setItems(List<ItemVenta> items) {
		this.items = items;
	}
	

}
